/*
 * @Author: yangni
 * @Date: 2023-10-19 20:57:53
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-01-28 22:12:14
 * @Description: 空调详情页
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/pages/devices/device_tab/components/detail_grid_widget.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/fire_fighting/air_cool_fire_detail/air_cool_fire_detail_controller.dart';
import 'package:yt_devops/pages/devices/device_tab/utils/device_util.dart';
import 'package:yt_devops/utils/enums.dart';

class FireFightingDetailPage extends GetWidget<FireFightingDetailController> {
  const FireFightingDetailPage({Key? key}) : super(key: key);

  @override
  FireFightingDetailController get controller =>
      Get.put(FireFightingDetailController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarWidget.withRightActions(controller.title),
      body: GetBuilder<FireFightingDetailController>(
        dispose: (state) => Get.delete<FireFightingDetailController>(),
        builder: (_) => StreamBuilder(
          stream: controller.dataStream,
          builder: (context, snapshot) => ListView.builder(
            padding: EdgeInsets.zero,
            itemBuilder: (context, index) => DeviceUtil.blockContainer(
              Column(
                children: [
                  DetailGridWidget(
                    title: controller.airInfos[index].title.toString(),
                    items: controller.airInfos[index].items,
                    dataSource: snapshot.data,
                    isSingleRow: true,
                    isLightTtext:
                        controller.connectStatus != ConnectStatusType.on,
                  ),
                ],
              ),
            ),
            itemCount: controller.airInfos.length,
          ),
        ),
      ),
    );
  }
}
